<?php
/**
 * Created by PhpStorm.
 * User: ZEN
 * Date: 2017/2/14
 * Time: 下午4:02
 */

/**
 * 自php5.4起，trait解决继承问题的代码复用机制
 * 文档：http://php.net/manual/zh/language.oop5.traits.php
 */

trait test
{
    function sayHello1(){
        echo 12;
    }
    function sayHello2(){
        echo 234;
    }
}

class Child1 extends Test1
{
    use test;
}
class Child2 extends Test2
{
    use test;
}

class Test1
{
    public function sayhi()
    {
        echo 'hi';
    }
}
class Test2
{
    public function saybye()
    {
        echo 'bye';
    }
}

$t = new Child1();
$t->sayHello1();
$t->sayhi();